﻿using System;
using System.ComponentModel.DataAnnotations;
using AutoMapper;

namespace CashFlow.Entities.Models
{
	public class InitialBalanceEditModel
	{
		#region Constructors
		static InitialBalanceEditModel()
		{
			Mapper.CreateMap<Tenant, InitialBalanceEditModel>();
			Mapper.CreateMap<InitialBalanceEditModel, Tenant>();
		}
		#endregion

		#region Fields and Properties
		[DataType(DataType.Date)]
		[DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:d}")]
		[Display(Name = "Date")]
		[Required(AllowEmptyStrings = false, ErrorMessage = "Please enter the date")]
		public DateTime InitialBalanceDate { get; set; }

		[Display(Name = "Amount")]
		[DataType(DataType.Currency)]
		[Required(AllowEmptyStrings = false, ErrorMessage = "Please enter a valid amount")]
		//[Range(0, 100000000)]
		public double InitialBalanceAmount { get; set; }
		#endregion

		#region Mappers
		public static explicit operator Tenant(InitialBalanceEditModel model)
		{
			var entity = Mapper.Map<InitialBalanceEditModel, Tenant>(model);
			return entity;
		}

		public static explicit operator InitialBalanceEditModel(Tenant entity)
		{
			var model = Mapper.Map<Tenant, InitialBalanceEditModel>(entity);
			return model;
		}
		#endregion	

	}
}
